#!/usr/bin/env python
#-*- coding: utf-8 -*-
#
# BSD License
# Copyright (c) 2011, Wang Qiang
# All rights reserved.

"""
Gravatar image API
"""

import urllib, hashlib


def GetGravatarUrl(email, size, default):
    """
    Get the Gravatar image url.
    @param email: user email
    @param size: size of image
    @param default: default image url
    """
    gravatar_url = "http://www.gravatar.com/avatar/" + \
            hashlib.md5(email.lower()).hexdigest() + "?"
    gravatar_url += urllib.urlencode({'d':default, 's':str(size)})
    return gravatar_url
